//
//  IslanSelectView.m
//  diaoyuren
//
//  Created by 钓鱼人 on 16/3/1.
//  Copyright © 2016年 game. All rights reserved.
//

#import "IslanSelectView.h"
#import "Masonry.h"
#define Btnhight (SCREEN_HEIGHT*0.06)

@interface IslanSelectView ()

@end

@implementation IslanSelectView


-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        [self CreatUI];
        [self BottomLineCreat];
        
        
        
        
    }
    return self;
}



-(void)CreatUI{
    self.fujin = [self CreatbtnWhithTitle:@"附近"];
    self.fujin.imageEdgeInsets = UIEdgeInsetsMake(0, 60, 0, 0);
    self.fujin.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 25);
    self.fujin.frame  = CGRectMake(0, 0, SCREEN_WIDTH/3-1, Btnhight);
    [self.fujin addTarget:self action:@selector(FujinClick:) forControlEvents:UIControlEventTouchUpInside];
    
    self.zuijin = [self CreatbtnWhithTitle:@"离我最近"];
    self.zuijin.imageEdgeInsets = UIEdgeInsetsMake(0, 85, 0, 0);
    self.zuijin.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 15);
    self.zuijin.frame  = CGRectMake(SCREEN_WIDTH/3+1,0 , SCREEN_WIDTH/3-1, Btnhight);
    [self.zuijin addTarget:self action:@selector(ZuijinClick:) forControlEvents:UIControlEventTouchUpInside];
    
    
    self.shaixuan = [self CreatbtnWhithTitle:@"筛选"];
    self.shaixuan.imageEdgeInsets = UIEdgeInsetsMake(0, 60, 0, 0);
    self.shaixuan.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 25);
    self.shaixuan.frame  = CGRectMake(SCREEN_WIDTH*2/3+1, 0, SCREEN_WIDTH/3-1, Btnhight);
    [self.shaixuan addTarget:self action:@selector(ShaiXuanClick:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    UIView *lin1 = [[UIView alloc]initWithFrame:CGRectMake( SCREEN_WIDTH/3,10, 0.5, Btnhight-20)];
    lin1.backgroundColor = linColor;
    [self addSubview:lin1];
    
    
    UIView *lin2 = [[UIView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH*2/3, 10, 0.5, Btnhight-20)];
    lin2.backgroundColor = linColor;
    [self addSubview:lin2];

}

-(void)BottomLineCreat{

   UIView *lin = [UIView new];
    lin.backgroundColor  = linColor;
    [self addSubview:lin];
    
    [lin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self);
        make.height.equalTo(@0.5);
    }];

}
/**
 *  点击 附近
 */
-(void)FujinClick:(UIButton *)btn{
    
    btn.selected = !btn.selected;
    [self.deleget FujinClick:btn];
    
    self.zuijin.selected = NO;
    [self.deleget ZuijinClick:self.zuijin];
    
    self.shaixuan.selected = NO;
    [self.deleget ShaiXuanClick:self.shaixuan];
    
}

/**
 *  点击 离我最近
 */
-(void)ZuijinClick:(UIButton *)btn{
    
    btn.selected = !btn.selected;
    [self.deleget ZuijinClick:btn];
    
    self.fujin.selected = NO;
    [self.deleget FujinClick:self.fujin];
    
    
    self.shaixuan.selected = NO;
    [self.deleget ShaiXuanClick:self.shaixuan];

}
/**
 *  点击  筛选
 */
-(void)ShaiXuanClick:(UIButton *)btn{
    
    btn.selected = !btn.selected;
    [self.deleget ShaiXuanClick:btn];
    
    self.zuijin.selected = NO;
    [self.deleget ZuijinClick:self.zuijin];
    
    self.fujin.selected = NO;
    [self.deleget FujinClick:self.fujin];
    
  
}

-(UIButton *)CreatbtnWhithTitle:(NSString *)title{
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitle:title forState:UIControlStateNormal];
    
    [btn setImage:[UIImage imageNamed:@"icon-arrow-Down"] forState:UIControlStateNormal];
    
    [btn setImage:[UIImage imageNamed:@"pack_up"] forState:UIControlStateSelected];
    
    btn.titleLabel.font = Boldfont(SCREEN_WIDTH*0.04);
    [btn setTitleColor:RGBA(0, 0, 0, 0.6) forState:UIControlStateNormal];
    
    [btn setTitleColor:mainColor forState:UIControlStateSelected];
    btn.backgroundColor = [UIColor whiteColor];
    [self addSubview:btn];
    
    return btn;
}

-(void)awakeFromNib{
    
   
  
}
@end
